package com.udata.shared.exception;

import java.io.Serializable;

import com.google.gwt.user.client.rpc.IsSerializable;

public class OperationException extends Exception implements IsSerializable,
		Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -176857438601464986L;
	private String message = "";
	private Exception rootException = null;

	private String sourceObjectClass = "";

	public OperationException(String m, Exception e) {
		message = m;
		rootException = e;
	}

	public OperationException() {

	}

	public OperationException(String msg) {
		super(msg);
		this.message = msg;
	}

	public OperationException(String objectClass, Exception e, String message) {
		this.message = message;
		this.sourceObjectClass = objectClass;
		this.rootException = e;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		String str = "";
		str = "Operation Type : " + sourceObjectClass;
		str += "\nException :"
				+ (rootException == null ? "" : rootException.toString());
		str += "\nMessage : " + message;

		return str;
	}

	/**
	 * @param message
	 *            the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}

	public Exception getRootException() {
		return rootException;
	}

	public void setRootException(Exception rootException) {
		this.rootException = rootException;
	}

}
